package edu.jxnu.zhangjinsong.unemploymenttracker.service;

import edu.jxnu.zhangjinsong.unemploymenttracker.entity.Person;
import edu.jxnu.zhangjinsong.unemploymenttracker.mapper.PersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PersonService {

    @Autowired
    private PersonMapper personMapper;

    /**
     * 获取所有人员信息
     */
    public List<Person> getAllPersons() {
        return personMapper.findAll();
    }

    /**
     * 根据ID获取人员信息
     */
    public Person getPersonById(String id) {
        return personMapper.findById(id);
    }

    /**
     * 保存人员信息
     */
    public boolean savePerson(Person person) {
        return personMapper.insert(person) > 0;
    }

    /**
     * 更新人员信息
     */
    public boolean updatePerson(String id, Person personDetails) {
        personDetails.setId(id);
        return personMapper.update(personDetails) > 0;
    }

    /**
     * 删除人员信息
     */
    public boolean deletePerson(String id) {
        return personMapper.delete(id) > 0;
    }
}